﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Audio;

namespace Emptiness.Utils
{
    public class MusicUtil
    {
        private static MusicUtil singleton = null;
        private Song song;
        private SoundEffect soundEffect;

        public static MusicUtil GetMusicUtil()
        {
            if (singleton == null)
            {
                singleton = new MusicUtil();
                MediaPlayer.IsRepeating = true;
            }
            return singleton;
        }


        public void Play(string songName)
        {
            if (song != null)
                Stop();
            song = EmptinessGame.GameContentManager.Load<Song>(@"BgMusic\" + songName);
            MediaPlayer.Play(song);
        }

        public void Stop()
        {
            MediaPlayer.Stop();
            song = null;
        }

        public void PlaySoundEffects(string soundEffectName)
        {
            soundEffect = EmptinessGame.GameContentManager.Load<SoundEffect>(@"SoundEffects\" + soundEffectName);
            soundEffect.Play();
        }
    }
}
